<template>
  <view>
    <video v-if="type != 2" id="videoElement1" :src="url + info.no" is-live autoplay controls></video>
    <video v-if="type == 2" id="videoElement2" :src="url2 + info.deviceNo + '-' + info.flvTimestamp + '.flv'" is-live autoplay controls></video>
    <!-- {{url2 + info.deviceNo + '-' + info.flvTimestamp + '.flv'}} -->
  </view>
</template>

<script>
// import flvjs from "flv.js"
export default {
  props: ['info', 'type'],
  components: {},
  data() {
    return {
      url: 'rtmp://223.84.153.141:11935/live/',
      url2: `http://223.84.153.141:8901/profile/`,
      vtype: 1, //1直播，2视频记录
      player: null,
      playerArr: [],
    };
  },
  mounted() {
    // this.initFlv('test1');
    if (this.type == 2) {
      uni.setNavigationBarTitle({
        title: '视频查看'
      })
    }
    console.log(this.info.flvTimestamp);
  },
  beforeDestroy() {
  },
  methods: {
    initFlv() {
      // let dom = document.getElementById('videoElement');
      // let url = `http://223.84.153.141:19080/live/test1.flv`;
      // let flvPlayer = flvjs.createPlayer({
      //   type: 'flv',
      //   url
      // });
      // flvPlayer.attachMediaElement(dom);
      // flvPlayer.load();
      // flvPlayer.play();
    },
  }
}
</script>

<style lang="scss" scoped>
video {
  width: 100%;
  height: 200px;
}
</style>
